package io.renren.modules.udp.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.udp.entity.R5rmCompanyEntity;
import io.renren.modules.udp.service.R5rmCompanyService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 发电企业
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-02-11 13:05:33
 */
@RestController
@RequestMapping("udp/r5rmcompany")
public class R5rmCompanyController {
    @Autowired
    private R5rmCompanyService r5rmCompanyService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("udp:r5rmcompany:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = r5rmCompanyService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{coId}")
    @RequiresPermissions("udp:r5rmcompany:info")
    public R info(@PathVariable("coId") Integer coId){
		R5rmCompanyEntity r5rmCompany = r5rmCompanyService.selectById(coId);

        return R.ok().put("r5rmCompany", r5rmCompany);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("udp:r5rmcompany:save")
    public R save(@RequestBody R5rmCompanyEntity r5rmCompany){
		r5rmCompanyService.insert(r5rmCompany);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("udp:r5rmcompany:update")
    public R update(@RequestBody R5rmCompanyEntity r5rmCompany){
		r5rmCompanyService.updateById(r5rmCompany);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("udp:r5rmcompany:delete")
    public R delete(@RequestBody Integer[] coIds){
		r5rmCompanyService.deleteBatchIds(Arrays.asList(coIds));

        return R.ok();
    }

}
